package cn.gson.springboot.controllers;


import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;

import cn.gson.springboot.model.service.RegistrFromService;


@Controller
public class baobiaoController {
	@Autowired
	 private RegistrFromService  guahao;	
	
	
		@RequestMapping("baobiao")
		public void baobiao() {
			
		}
		
		@RequestMapping("demo1")
		public void demo1() {
			
		}
		
		
		@PostMapping("RegistrFromAll")
		@ResponseBody
		public JSONArray RegistrFromAll(String start) {
			if(start.trim().equals("")) {
				Date date=new Date();
				SimpleDateFormat formatter  =new SimpleDateFormat("yyyy");
				String shijian = formatter.format(date);
				Integer oo= Integer.parseInt(shijian);
				JSONArray uu = guahao.renshu(oo);
				return uu;  
			}else{
				/*System.out.println("777"+start);
				Date date =new Date(start);
				SimpleDateFormat formatter  =new SimpleDateFormat("yyyy");
				String shijian = formatter.format(date);*/
				String shijian = null;				
				if(start.length()>0) {
					shijian=start.substring(0,4);
					
				}				
				Integer oo= Integer.parseInt(shijian);
				JSONArray uu = guahao.renshu(oo);					
				return uu; 
			}
			
		       
		}
	

}
